﻿<Window
	x:Class="WPFTestHarness.GradientTestWindow"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:bme="clr-namespace:BlendModeEffectLibrary;assembly=BlendModeEffectLibrary"
	xmlns:cp="clr-namespace:ColorPicker;assembly=ColorPicker"
	Title="Blend Mode Effects Test Window (Gradients)"
	Height="700"
	Width="800"
>
	<Window.Resources>
		<ImageBrush x:Key="imageBrushTexture">
			<ImageBrush.ImageSource>
				<DrawingImage>
					<DrawingImage.Drawing>
						<GeometryDrawing>
							<GeometryDrawing.Geometry>
								<RectangleGeometry Rect="0,0,1,1"/>
							</GeometryDrawing.Geometry>
							<GeometryDrawing.Brush>
								<LinearGradientBrush StartPoint="0,0" EndPoint="1,0" Opacity="{Binding ElementName=bOpacitySlider, Path=Value}">
									<LinearGradientBrush.Transform>
										<RotateTransform Angle="{Binding ElementName=bRotationSlider, Path=Value}"/>
									</LinearGradientBrush.Transform>
									<GradientStop Color="{Binding ElementName=bStop0ColorPicker, Path=Color}" Offset="0"/>
									<GradientStop Color="{Binding ElementName=bStop1ColorPicker, Path=Color}" Offset="1"/>
								</LinearGradientBrush>
							</GeometryDrawing.Brush>
						</GeometryDrawing>
					</DrawingImage.Drawing>
				</DrawingImage>
			</ImageBrush.ImageSource>
		</ImageBrush>
	</Window.Resources>

	<Grid>
		<Grid.Background>
			<ImageBrush ImageSource="Resources/MSwanson - Wide - Water 06.jpg" Stretch="UniformToFill"/>
		</Grid.Background>

		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="210"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="*"/>
		</Grid.ColumnDefinitions>

		<TextBlock
			Grid.Row="0"
			Grid.Column="0"
			HorizontalAlignment="Center"
			Margin="5"
			FontFamily="Verdana"
			FontSize="24"
			Text="A"
		/>
		<TextBlock
			Grid.Row="0"
			Grid.Column="1"
			HorizontalAlignment="Center"
			Margin="5"
			FontFamily="Verdana"
			FontSize="24"
			Text="B"
		/>
		<TextBlock
			Grid.Row="0"
			Grid.Column="2"
			HorizontalAlignment="Center"
			Margin="5"
			FontFamily="Verdana"
			FontSize="24"
			Text="R"
		/>

		<Border
			x:Name="aBorder"
			Grid.Row="1"
			Grid.Column="0"
			Width="200"
			Height="200"
		>
			<Border.Background>
				<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
					<LinearGradientBrush.Transform>
						<RotateTransform Angle="{Binding ElementName=aRotationSlider, Path=Value}"/>
					</LinearGradientBrush.Transform>
					<GradientStop Color="{Binding ElementName=aStop0ColorPicker, Path=Color}" Offset="0"/>
					<GradientStop Color="{Binding ElementName=aStop1ColorPicker, Path=Color}" Offset="1"/>
				</LinearGradientBrush>
			</Border.Background>
		</Border>
		<Border
			x:Name="bBorder"
			Grid.Row="1"
			Grid.Column="1"
			Width="200"
			Height="200"
		>
			<Border.Background>
				<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
					<LinearGradientBrush.Transform>
						<RotateTransform Angle="{Binding ElementName=bRotationSlider, Path=Value}"/>
					</LinearGradientBrush.Transform>
					<GradientStop Color="{Binding ElementName=bStop0ColorPicker, Path=Color}" Offset="0"/>
					<GradientStop Color="{Binding ElementName=bStop1ColorPicker, Path=Color}" Offset="1"/>
				</LinearGradientBrush>
			</Border.Background>
		</Border>
		<Border
			x:Name="resultBorder"
			Grid.Row="1"
			Grid.Column="2"
			Width="200"
			Height="200"
		>
			<Border.Background>
				<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" Opacity="{Binding ElementName=aOpacitySlider, Path=Value}">
					<LinearGradientBrush.Transform>
						<RotateTransform Angle="{Binding ElementName=aRotationSlider, Path=Value}"/>
					</LinearGradientBrush.Transform>
					<GradientStop Color="{Binding ElementName=aStop0ColorPicker, Path=Color}" Offset="0"/>
					<GradientStop Color="{Binding ElementName=aStop1ColorPicker, Path=Color}" Offset="1"/>
				</LinearGradientBrush>
			</Border.Background>
			<Border.Effect>
				<bme:NormalEffect>
					<bme:NormalEffect.BInput>
						<ImageBrush>
							<ImageBrush.ImageSource>
								<DrawingImage>
									<DrawingImage.Drawing>
										<GeometryDrawing>
											<GeometryDrawing.Geometry>
												<RectangleGeometry Rect="0,0,1,1"/>
											</GeometryDrawing.Geometry>
											<GeometryDrawing.Brush>
												<LinearGradientBrush StartPoint="0,0" EndPoint="1,0" Opacity="{Binding ElementName=bOpacitySlider, Path=Value}">
													<LinearGradientBrush.Transform>
														<RotateTransform Angle="{Binding ElementName=bRotationSlider, Path=Value}"/>
													</LinearGradientBrush.Transform>
													<GradientStop Color="{Binding ElementName=bStop0ColorPicker, Path=Color}" Offset="0"/>
													<GradientStop Color="{Binding ElementName=bStop1ColorPicker, Path=Color}" Offset="1"/>
												</LinearGradientBrush>
											</GeometryDrawing.Brush>
										</GeometryDrawing>
									</DrawingImage.Drawing>
								</DrawingImage>
							</ImageBrush.ImageSource>
						</ImageBrush>
					</bme:NormalEffect.BInput>
				</bme:NormalEffect>
			</Border.Effect>
		</Border>

		<StackPanel
			Grid.Row="2"
			Grid.Column="0"
			Orientation="Vertical"
		>
			<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
				<TextBlock Text="Rotation" VerticalAlignment="Center" Foreground="DarkBlue"/>
				<Slider
					x:Name="aRotationSlider"
					Width="150"
					Margin="5"
					IsSnapToTickEnabled="True"
					Minimum="-360"
					Maximum="360"
					Value="0"
					LargeChange="10"
				/>
				<TextBlock
					Text="{Binding ElementName=aRotationSlider, Path=Value}"
					VerticalAlignment="Center"
				/>
			</StackPanel>
			<TextBlock Text="A Gradient Stop 0" Margin="30,0,0,0" Foreground="DarkBlue"/>
			<cp:ColorPicker
				Name="aStop0ColorPicker"
				Width="200"
				Margin="10"
				Color="#FFFFFFFF"
			/>
			<TextBlock Text="A Gradient Stop 1" Margin="30,0,0,0" Foreground="DarkBlue"/>
			<cp:ColorPicker
				Name="aStop1ColorPicker"
				Width="200"
				Margin="10"
				Color="#FF000000"
			/>
			<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
				<TextBlock Text="Opacity" VerticalAlignment="Center" Foreground="DarkBlue"/>
				<Slider
					x:Name="aOpacitySlider"
					Width="150"
					Margin="5"
					Minimum="0"
					Maximum="1"
					SmallChange="0.1"
					LargeChange="0.2"
					Value="1"
				/>
				<TextBlock
					Text="{Binding ElementName=aOpacitySlider, Path=Value, StringFormat=F1}"
					VerticalAlignment="Center"
				/>
			</StackPanel>
		</StackPanel>

		<StackPanel
			Grid.Row="2"
			Grid.Column="1"
			Orientation="Vertical"
		>
			<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
				<TextBlock Text="Rotation" VerticalAlignment="Center" Foreground="DarkBlue"/>
				<Slider
					x:Name="bRotationSlider"
					Width="150"
					Margin="5"
					IsSnapToTickEnabled="True"
					Minimum="-360"
					Maximum="360"
					Value="0"
					LargeChange="10"
				/>
				<TextBlock
					Text="{Binding ElementName=bRotationSlider, Path=Value}"
					VerticalAlignment="Center"
				/>
			</StackPanel>
			<TextBlock Text="B Gradient Stop 0" Margin="30,0,0,0" Foreground="DarkBlue"/>
			<cp:ColorPicker
				Name="bStop0ColorPicker"
				Width="200"
				Margin="10"
				Color="#FF000000"
			/>
			<TextBlock Text="B Gradient Stop 1" Margin="30,0,0,0" Foreground="DarkBlue"/>
			<cp:ColorPicker
				Name="bStop1ColorPicker"
				Width="200"
				Margin="10"
				Color="#FFFFFFFF"
			/>
			<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
				<TextBlock Text="Opacity" VerticalAlignment="Center" Foreground="DarkBlue"/>
				<Slider
					x:Name="bOpacitySlider"
					Width="150"
					Margin="5"
					Minimum="0"
					Maximum="1"
					SmallChange="0.1"
					LargeChange="0.2"
					Value="1"
				/>
				<TextBlock
					Text="{Binding ElementName=bOpacitySlider, Path=Value, StringFormat=F1}"
					VerticalAlignment="Center"
				/>
			</StackPanel>
		</StackPanel>

		<ListBox
			x:Name="effectsListBox"
			Grid.Row="2"
			Grid.Column="2"
			Margin="30,10"
			SelectionChanged="effectsListBox_SelectionChanged"
		/>
	</Grid>
</Window>
